<template>
  <div style="padding:15px;">
    <vxe-toolbar id="toolbarId" :setting="{storage: true}" export :refresh="{query: findList}">
      <template v-slot:buttons>
        <el-button @click="findList">查询</el-button>
        <el-date-picker
          v-model="listQuery.gmtCreatedStart"
          type="date"
          placeholder="开始日期"
          value-format="yyyy-MM-dd"
          style="width: 140px;"
        />
        <el-date-picker
          v-model="listQuery.gmtCreatedEnd"
          type="date"
          placeholder="结束日期"
          value-format="yyyy-MM-dd"
          style="width: 140px;"
        />
      </template>
    </vxe-toolbar>
    <vxe-table
      ref="xTable"
      resizable
      border
      highlight-current-row
      highlight-hover-row
      row-id="id"
      class="mytable-footer"
      height="700"
      :data="tableData"
      :loading="loading"
      remote-sort
      @sort-change="sortList"
    >
      <vxe-table-column>
        <vxe-table-column
          field="name"
          title="姓名"
          show-header-overflow
          show-overflow
          min-width="100"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.name" placeholder="请输入姓名" width="100" clearable />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="phone"
          title="手机号"
          show-header-overflow
          show-overflow
          min-width="100"
          sortable
        />
        <template v-slot:header="{ column }">
          <el-input v-model="listQuery.phone" placeholder="请输入手机号" width="100" clearable />
        </template>
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="orderCount"
          title="运单数"
          show-header-overflow
          show-overflow
          min-width="100"
        />
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="deliveryFeePractical"
          title="运费（元）"
          show-header-overflow
          show-overflow
          min-width="100"
        />
      </vxe-table-column>
      <vxe-table-column>
        <vxe-table-column
          field="basicGrade"
          title="评价分数"
          show-header-overflow
          show-overflow
          min-width="100"
        />
      </vxe-table-column>
    </vxe-table>
    <vxe-pager
      :loading="loading"
      :current-page.sync="listQuery.pageNum"
      :page-size.sync="listQuery.pageSize"
      :total="total"
      :layouts="['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
      @page-change="handlePageChange"
    />
  </div>
</template>
<script>
import Vue from "vue";
import "xe-utils";
import VXETable from "vxe-table";
import "vxe-table/lib/index.css";
import XEUtils from "xe-utils";
import VXEUtils from "vxe-utils";
Vue.use(VXETable, VXEUtils, XEUtils, {
  mounts: ["cookie"]
});
import request from "@/utils/request";
export default {
  name: "PartyList",
  components: {},
  data() {
    return {
      message: "",
      loading: false,
      tableData: [],
      copy: false,
      total: 0,
      listQuery: {
        name: "", // 名称
        phone: "", // 电话
        orderCount: "", // 订单数
        deliveryFeePractical: "", // 运费（元）
        basicGrade: "", // 评价分数
        gmtCreatedStart: "", // 创建时间起始
        gmtCreatedEnd: "", // 创建时间终止
        pageNum: 1,
        pageSize: 10,
        sortField: "",
        sortType: ""
      },
      roleList: []
    };
  },
  created() {
    this.findList();
  },
  methods: {
    findList() {
      this.loading = true;
      return new Promise(resolve => {
        request({
          url: "ntocc-tms-api/statistics/driverOrderStatistics",
          method: "get",
          params: this.listQuery
        }).then(response => {
          this.tableData = response.data.records;
          this.total = response.data.total;
          this.loading = false;
          resolve();
        });
      });
    },
    // 排序
    sortList({ column, property, order }) {
      if (order) {
        this.listQuery.sortField = property;
        this.listQuery.sortType = order;
      } else {
        this.listQuery.sortField = "";
      }
      this.findList();
    },
    // 分页handle
    handlePageChange({ currentPage, pageSize }) {
      this.listQuery.pageNum = currentPage;
      this.listQuery.pageSize = pageSize;
      this.findList();
    }
  }
};
</script>
<style>
.vxe-table .vxe-body--column:not(.col--ellipsis),
.vxe-table .vxe-footer--column:not(.col--ellipsis),
.vxe-table .vxe-header--column:not(.col--ellipsis) {
  padding: 6px 0;
}
.vxe-toolbar {
  padding: 0 0 10px 0;
}
</style>

